Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

[chore] Simplify @expo/steps from dual ESM/CJS to plain CJS#658

Merged
sjchmiela merged 10 commits intomainfrom
sjchmiela/simplify-steps-to-cjs
Jan 23, 2026
Merged

[chore] Simplify @expo/steps from dual ESM/CJS to plain CJS#658
sjchmiela merged 10 commits intomainfrom
sjchmiela/simplify-steps-to-cjs

Conversation

@sjchmiela
Copy link
Copy Markdown
Contributor

@sjchmiela sjchmiela commented Jan 9, 2026

Why

The @expo/steps package was configured with a dual ESM/CJS build setup that added unnecessary complexity:

  • Two TypeScript config files (tsconfig.build.json and tsconfig.build.commonjs.json)
  • A complex build.sh script that used sed to rename .js files to .cjs
  • ESM-specific workarounds like this-file package and import.meta.url
  • .js extensions required on all imports

This complexity was not needed as the package runs in Node.js where CJS is well supported, and other packages in the workspace (like @expo/eas-build-job) use plain CJS successfully and we're not planning to move off of CJS without moving all the rest of the packages to ESM too. Having this package as the only package with ESM enabled is a bit weird.

How

  • Removed "type": "module" from package.json
  • Simplified exports to plain main and types fields pointing to dist/
  • Replaced dual tsconfig setup with a single tsconfig.build.json using module: \"commonjs\"
  • Deleted build.sh script and replaced with simple tsc command
  • Removed .js extensions from all import statements (~40 files)
  • Replaced this-file package usage with native __dirname
  • Replaced import.meta.url with __dirname equivalents
  • Simplified Jest configuration to use standard ts-jest preset
  • Updated cli.sh to point to dist/cli/cli.js
  • Removed this-file and chokidar-cli dev dependencies

Test Plan

  • yarn build completes successfully
  • yarn test passes all 281 tests across 20 test suites

@sjchmiela sjchmiela marked this pull request as ready for review January 12, 2026 11:10
@sjchmiela sjchmiela requested a review from hSATAC January 12, 2026 11:10
Copy link
Copy Markdown
Contributor

@hSATAC hSATAC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to have a rebase hell after this was merged. 😭

@sjchmiela
Copy link
Copy Markdown
Contributor Author

oh no

maybe git merge will be more helpful?

@sjchmiela
Copy link
Copy Markdown
Contributor Author

hmm most of your changes are in build-tools so maybe this few steps files won't be this bad

- Remove 'type: module' field
- Simplify main/types to use single dist/ directory
- Remove dual exports field
- Update build scripts to use simple tsc
- Remove chokidar-cli (no longer needed for watch)
- Remove this-file dependency (replaced with native __dirname)
- Update tsconfig.build.json to use commonjs module and output to dist/
- Delete tsconfig.build.commonjs.json (no longer need dual build)
- Delete build.sh (replaced by simple tsc command in package.json)
Remove ESM-style .js extensions from all relative imports in source files.
CommonJS module resolution doesn't require explicit extensions.
- Replace this-file createContext() with native __dirname
- Remove import.meta.url usage in test files (use built-in __dirname)
- Update SCRIPTS_PATH to point to dist/scripts instead of dist_commonjs/scripts
- Update cli.sh to reference dist/cli/cli.js instead of dist_commonjs/cli/cli.cjs
- Simplify jest.config.cjs to use standard ts-jest preset (not ESM)
- Remove moduleNameMapper for .js extensions (no longer needed)
- Remove custom transform with useESM option
- Remove this-file import from runCustomFunction-test.ts
- Update SCRIPTS_PATH reference to runCustomFunction.js (not .cjs)
@sjchmiela sjchmiela force-pushed the sjchmiela/simplify-steps-to-cjs branch from c9fcd40 to 2dc1aaa Compare January 23, 2026 10:30
@sjchmiela sjchmiela requested a review from hSATAC January 23, 2026 10:32
@sjchmiela
Copy link
Copy Markdown
Contributor Author

Going to publish steps as v2 so it doesn't break anyone's code (specifically, user functions created with create-eas-build-function).

@sjchmiela
Copy link
Copy Markdown
Contributor Author

Or… maybe we don't need to do that because functions are commonjs?

Copy link
Copy Markdown
Contributor

@hSATAC hSATAC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find anything left out. This looks generally good to me.

@sjchmiela sjchmiela merged commit a4b80d0 into main Jan 23, 2026
5 checks passed
@sjchmiela sjchmiela deleted the sjchmiela/simplify-steps-to-cjs branch January 23, 2026 13:15
sjchmiela added a commit to expo/eas-cli that referenced this pull request Jan 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants